package com.lanhai.ads.redis;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

/**
 * 备注：redis数据set事件
 */
@Slf4j
@Component
public class RedisKeyListener implements MessageListener {

    /**
     * 针对redis数据失效事件，进行数据处理
     *
     * @param message
     * @param pattern
     */
    @Override
    public void onMessage(Message message, byte[] pattern) {
        try {
            System.out.println("set事件->"+message.toString());
            System.out.println(new String(pattern));

        } catch (Exception e) {
            e.printStackTrace();
            log.error("【redis过期事件异常】：" + e.getMessage());
        }
    }
}
